#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int t;
	cin>>t;
	while(t--)
	{
		int n,m,k;
		cin>>n>>m>>k;
		int line[n+2]={0};
		int row[m+2]={0};
		for(int i = 0;i<k;i++)
		{
			int x,y;
			cin>>x>>y;
			line[x] = 1;
			row[y] = 1;
		}
		int cntl = 0,cntr = 0;
		int ans = 0;
		for(int i = 1;i<=n;i++)
		{
			if(line[i]==0)
			{
				ans += m;
				cntl++;
			}
		}
		for(int i = 1;i<=m;i++)
		{
			if(row[i]==0)
			{
				ans += n;
				cntr++;
			}
		}
		cout<<ans-cntl*cntr<<endl;
	}
}
